home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / commands / machine.c < prev    next >
C/C++ Source or Header  |  1990-07-23  |  3KB  |  131 lines

  1. /* machine.c, 27-03-1990, F. Meulenbroeks
  2.  * usage: machine [machine name]
  3.  *        chip [chip name]
  4.  * where machine name or chip name are the same as the macros from 
  5.  * <minix/config.h>
  6.  * 
  7.  * When executed without arguments this program returns either the machine name
  8.  * or the chip name as found in <minix/config.h>
  9.  * the chip name is returned if argv[0] ends on "chip". 
  10.  * otherwise the machine name is returned
  11.  *
  12.  * when executed with an argument that argument is (case insensitive)
  13.  * compared with the machine name, and depending on whether these match
  14.  * or not 0 or 1 is returned as the exit code. In this case nothing is printed
  15.  */
  16.  
  17. #include <minix/config.h>
  18. #include <stdio.h>
  19. #include <ctype.h>
  20.  
  21. main(argc, argv)
  22. int argc;
  23. char **argv;
  24. {
  25.   int i;
  26.   char *ptr;
  27.   
  28.   if (argc > 1)
  29.   {
  30.     for (i = strlen(argv[1]) - 1; i >= 0; i--) toupper(argv[1][i]);
  31.   }
  32.  
  33.   /* let ptr point to the last 4 characters of argv[0] */
  34.   ptr = argv[0] + strlen(argv[0]) - 4;
  35.   if (strncmp(ptr, "chip", 4) == 0)
  36.   {
  37. #if (CHIP == INTEL)
  38.     if (argc == 1) {
  39.       printf("INTEL\n");
  40.       exit(0);
  41.     }
  42.     else
  43.     if (strcmp(argv[1], "INTEL") == 0) exit(0);
  44.     else exit(1);
  45. #endif
  46.  
  47. #if (CHIP == M68000)
  48.     if (argc == 1) {
  49.       printf("M68000\n");
  50.       exit(0);
  51.     }
  52.     else
  53.     if (strcmp(argv[1], "M68000") == 0) exit(0);
  54.     else exit(1);
  55. #endif
  56.  
  57. #if (CHIP == SPARC)
  58.     if (argc == 1) {
  59.       printf("SPARC\n");
  60.       exit(0);
  61.     }
  62.     else
  63.     if (strcmp(argv[1], "SPARC") == 0) exit(0);
  64.     else exit(1);
  65. #endif
  66.  
  67. #if (CHIP != INTEL) & (CHIP != M68000) & (CHIP != SPARC)
  68.     if (argc == 1) printf("unknown\n");
  69.     exit(1);
  70. #endif
  71.   }
  72.   else {
  73. #if (MACHINE == IBM_PC)
  74.     if (argc == 1) {
  75.       printf("IBM_PC\n");
  76.       exit(0);
  77.     }
  78.     else
  79.     if (strcmp(argv[1], "IBM_PC") == 0) exit(0);
  80.     else exit(1);
  81. #endif
  82.  
  83. #if (MACHINE == SUN_4)
  84.     if (argc == 1) {
  85.       printf("SUN_4\n");
  86.       exit(0);
  87.     }
  88.     else
  89.     if (strcmp(argv[1], "SUN_4") == 0) exit(0);
  90.     else exit(1);
  91. #endif
  92.  
  93. #if (MACHINE == ATARI)
  94.     if (argc == 1) {
  95.       printf("ATARI\n");
  96.       exit(0);
  97.     }
  98.     else
  99.     if (strcmp(argv[1], "ATARI") == 0) exit(0);
  100.     else exit(1);
  101. #endif
  102.  
  103. #if (MACHINE == AMIGA)
  104.     if (argc == 1) {
  105.       printf("AMIGA\n");
  106.       exit(0);
  107.     }
  108.     else
  109.     if (strcmp(argv[1], "AMIGA") == 0) exit(0);
  110.     else exit(1);
  111. #endif
  112.  
  113. #if (MACHINE == MACINTOSH)
  114.     if (argc == 1) {
  115.       printf("MACINTOSH\n");
  116.       exit(0);
  117.     }
  118.     else
  119.     if (strcmp(argv[1], "MACINTOSH") == 0) exit(0);
  120.     else exit(1);
  121. #endif
  122.  
  123. #if (MACHINE != IBM_PC) & \
  124.     (MACHINE != SUN_4) & \
  125.     (MACHINE != ATARI) & (MACHINE != AMIGA) & (MACHINE != MACINTOSH)
  126.     if (argc == 1) printf("unknown\n");
  127.     exit(1);
  128. #endif
  129.   }
  130. }
  131.